<?php

namespace App\Http\Requests\Service\Visit;

use App\Http\Requests\ApiRequest;
use App\Models\Customer\DeviceAccount;
use Illuminate\Validation\Rule;

/**
 * @property string visit_type_id
 * @property string product_id
 * @property string device_account_id
 */
class AppScanProductRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $dev_acnt = new DeviceAccount;

        return [
            'product_id'        => 'required|int|min:1',
            'device_account_id' => ['required','int','min:1',
                Rule::exists($dev_acnt->getTable(), $dev_acnt->getKeyName())
            ],
        ];
    }

}
